cmake_minimum_required(VERSION 3.29)

project(demo2 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)


find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
# 设置 Python 相关路径
set(PYTHON_DIR "${CMAKE_SOURCE_DIR}/python")  # 根据实际路径调整
set(PYTHON_LIBRARIES "${CMAKE_SOURCE_DIR}/python/libs/python312.lib")
set(PYTHON_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/python/include")

# 添加Python include路径
include_directories(${PYTHON_INCLUDE_DIR})
# 在 CMake 中指定 Python 解释器的路径
set(PYTHON_EXECUTABLE "${CMAKE_SOURCE_DIR}/python/python.exe")

# 你可以使用以下命令调用 Python 脚本
add_custom_target(
        RunPythonScript ALL
        COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/gui/Python/py_test.py
        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/gui/Python
)

message(STATUS "PYTHON_LIBRARIES: ${PYTHON_LIBRARIES}")
message(STATUS "PYTHON_INCLUDE_DIR: ${PYTHON_INCLUDE_DIR}")
message(STATUS "PYTHON_EXECUTABLE: ${PYTHON_EXECUTABLE}")


find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)

# 设置编译告警
set(gcc_like_cxx "$<COMPILE_LANG_AND_ID:CXX,ARMClang,AppleClang,CLang,GNU,LCC)>")
set(msvc_cxx "$<COMPILE_LANG_AND_ID:CXX,MSVC>")

set(PYTHON_SCRIPT "${CMAKE_SOURCE_DIR}/gui/Python/py_test.py")
add_custom_target(
        RunPythonScript2 ALL
        COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_SCRIPT}
        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/gui/Python
)

#add_custom_command(demo2
#    "$<${gcc_like_cxx}:-Wall;-Wextra;-Wshadow;-Wunused>"
#        "$<${msvc}:-W3>"
#)


add_subdirectory(gui)
add_subdirectory(main)

